import socket
import threading
import SocketServer
import time
import pdb


_debug_=0

dbhome='/mnt/hda5/yuf/zx_suse11/ver1/offlinemgr/'

def client(ip, port, message):
    try:
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.connect((ip, port))
        sock.send(message)
        sock.send('\r\n\r\n')
        sock.close()
    except :
        pass

if __name__ == "__main__":

    ip,port='127.0.0.1',8010
    if _debug_:
        import bsddb3
        urltcdone=bsddb3.hashopen(dbhome+'urltcdone.db','c')
        for i in urltcdone.keys():
            del urltcdone[i]
        urltcdone.close()
    begintime=time.time()
    for i in range(1):
        #prf=threading.Thread(target=client,args=(ip,port,'http://news.sina.com.cn/'))
        #prf.start()
        client(ip,port,'http://www.baidu.com')
#    time.sleep(1)
#    for i in range(1000):
#        prf=threading.Thread(target=client,args=(ip,port,b'http://news.sina.com.cn/'))
#        prf.start()    
    print(time.time()-begintime)


